package com.duowei.kitchenshow.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.duowei.kitchenshow.R;
import com.duowei.kitchenshow.bean.Cfpb_csbh;
import com.duowei.kitchenshow.bean.Jycssz;

import org.litepal.crud.DataSupport;

import java.util.List;

public class RvBottomAdapter2 extends BaseQuickAdapter<Cfpb_csbh>{
    private List<Jycssz>jycsszList;
    public RvBottomAdapter2(List<Cfpb_csbh> data) {
        super(R.layout.bottom_item, data);
        if(jycsszList==null||jycsszList.size()<=0){
            jycsszList = DataSupport.findAll(Jycssz.class);
        }
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, Cfpb_csbh cfpb_csbh) {
        int position = baseViewHolder.getPosition();
        if(position==0){
            baseViewHolder.setText(R.id.tv_name,"全部");
        }else{
//            baseViewHolder.setText(R.id.tv_lbbm,cfpb_csbh.getFcsbh());
            for(int i=0;i<jycsszList.size();i++){
                Jycssz jycssz = jycsszList.get(i);
                if(jycssz.getCsbh().equals(cfpb_csbh.getFcsbh())){
                    baseViewHolder.setText(R.id.tv_name,jycssz.getCsmc());
                    break;
                }
            }
            baseViewHolder.setText(R.id.tv_num,cfpb_csbh.getSl()+"");
        }

        if(cfpb_csbh.isClick()){
            baseViewHolder.setBackgroundRes(R.id.rl_bottom,R.drawable.shape_blue_normal);
        }else{
            baseViewHolder.setBackgroundRes(R.id.rl_bottom,R.drawable.shape_cancel_click);
        }
    }
}
